Use a few more `chain_error` calls
authorAlex Crichton <alex@alexcrichton.com>
Tue, 16 May 2017 15:03:36 +0000 (08:03 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Tue, 16 May 2017 15:05:26 +0000 (08:05 -0700)
src/cargo/core/workspace.rs
src/cargo/util/errors.rs

index fd8531540f836c7838258bb7420c18fd457df165..80313728eee1b674e150a8951c721a1a9d793263 100644 (file)
@@ -8,7 +8,7 @@ use glob::glob;
 use core::{Package, VirtualManifest, EitherManifest, SourceId};
 use core::{PackageIdSpec, Dependency, Profile, Profiles};
 use ops;
-use util::{Config, CargoResult, Filesystem, human};
+use util::{Config, CargoResult, Filesystem, human, ChainError};
 use util::paths;
 
 /// The core abstraction in Cargo for working with a workspace of crates.
@@ -549,12 +549,12 @@ fn expand_member_path(path: &Path) -> CargoResult<Vec<PathBuf>> {
         Some(p) => p,
         None => return Ok(Vec::new()),
     };
-    let res = glob(path).map_err(|e| {
-        human(format!("could not parse pattern `{}`: {}", &path, e))
+    let res = glob(path).chain_error(|| {
+        human(format!("could not parse pattern `{}`", &path))
     })?;
     res.map(|p| {
-        p.or_else(|e| {
-            Err(human(format!("unable to match path to pattern `{}`: {}", &path, e)))
+        p.chain_error(|| {
+            human(format!("unable to match path to pattern `{}`", &path))
         })
     }).collect()
 }
index 3b1d35b6eee170189531d817072e3b93ca4f5f2d..dec97d0fe40362db00bd7baeecde6f644f6ade93 100644 (file)
@@ -11,6 +11,7 @@ use core::TargetKind;
 
 use curl;
 use git2;
+use glob;
 use semver;
 use serde_json;
 use term;
@@ -370,6 +371,8 @@ from_error! {
     term::Error,
     num::ParseIntError,
     str::ParseBoolError,
+    glob::PatternError,
+    glob::GlobError,
 }
 
 impl From<string::ParseError> for Box<CargoError> {
@@ -401,6 +404,8 @@ impl CargoError for ffi::NulError {}
 impl CargoError for term::Error {}
 impl CargoError for num::ParseIntError {}
 impl CargoError for str::ParseBoolError {}
+impl CargoError for glob::PatternError {}
+impl CargoError for glob::GlobError {}
 
 // =============================================================================
 // Construction helpers